package com.gxl.DaoImpl;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.gxl.Dao.ManagerDao;
import com.gxl.Entity.Manager;

public class ManagerDaoImpl extends HibernateDaoSupport implements ManagerDao{

	public Manager FindManager(String UserNo,String UserPassword)
	{
		String queryString = "from Manager  as s WHERE s.SNo = '"+UserNo+"' AND s.SPassword = '"+UserPassword+"'";
		List<Manager> userlist2=getHibernateTemplate().find(queryString);
		if(userlist2.size()!=0)
			return userlist2.get(0);
		else
			return null;
	}

	@Override
	public String InsertManager(Manager manager) {
		String queryString = "from Manager  as s WHERE s.SNo = '"+manager.getSNo()+"' AND s.SPassword = '"+manager.getSPassword()+"'";
		List<Manager> userlist3=getHibernateTemplate().find(queryString);
		if(userlist3.size()!=0)
		{	
			return "error";
		}
		else
		{
			System.out.println("123~~");
			this.getHibernateTemplate().save(manager);
			return "ok";
		}
	}

}
